#pragma once

class Material;
class PerspectiveCamera;
class RenderTask;
struct RenderTaskDesc;

/*--------------------------------------------------------------------------*/

struct ERenderFlag
{
	enum Type
	{
	    None					= 0,
	    AllowCustomTextures		= 1 << 0
	};
};

/*--------------------------------------------------------------------------*/

struct ERenderQuality
{
	enum Type
	{
	    LowQuality				= 0,
	    HighQuality,
	    BoundingBox
	};
};

/*--------------------------------------------------------------------------*/

class IRenderPhase;

class IRender
{
public:
	IRender(uint flags);
	virtual ~IRender();

	virtual const glm::mat4&	GetModelMatrix() const;
	virtual void				CalcModelMatrices();

	/*--------------------------------------------------------------------------*/

	virtual void				OnPreRender(const RenderTask* renderTask);
	virtual void				OnPostRender(const RenderTask* renderTask);
	virtual void				OnRender(const RenderTask* renderTask, uint camarg) = 0;

	/*--------------------------------------------------------------------------*/

	void						AddRenderTask(const RenderTaskDesc& renderTaskDesc);
	void						ClearTasks();

	/*--------------------------------------------------------------------------*/

	void						BindRenderTasks(IRenderPhase* rp);
	void						BindRenderTask(IRenderPhase* rp, uint i);

	/*--------------------------------------------------------------------------*/

	void						AddCustomTexture(const std::string& name, GLTexture* t);
	void						ClearCustomTextures();
	void						BindCustomTextures();

	/*--------------------------------------------------------------------------*/

protected:
	std::vector<RenderTask>				m_tasks;

private:
	uint						m_flags;
	std::map<std::string, GLTexture*>	m_customTextures;

	static glm::mat4					identityMatrix;
};